package com.tdwyz.fictionmanage.mapper;

import com.tdwyz.fictionmanage.pojo.FictionCategory;
import com.tdwyz.fictionmanage.pojo.Result;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FictionCategoryMapper {

    /**
     * 新增分类
     * @param categoryName
     * @param categoryAlias
     * @param id
     * @return
     */
    @Insert("insert into category(category_name,category_alias,create_user,create_time,update_time) values (#{categoryName},#{categoryAlias},#{id},now(),now())")
    boolean add(String categoryName, String categoryAlias, int id);


    @Select("select * from category where create_user = #{id}")
    List<FictionCategory> get(int id);

    @Select("select * from category where id = #{id}")
    FictionCategory getCategoryById(Integer id);




    @Update("update category set category_name =#{categoryName},category_alias=#{categoryAlias},update_time=now() where id = #{id}")
    boolean update(FictionCategory fictionCategory);

    @Select("select * from category")
    List<FictionCategory> getall();


    @Delete("delete from category where id = #{id}")
    boolean delete(Integer id);
}
